﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class rest_school_detail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string Sname = Request.QueryString["Sname"];
        Response.Write("请确认'" + Sname + "'休学 ");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Sno = Request.QueryString["Sno"];

        string conn = "Data Source= . ;Initial Catalog=XSXK; User ID=sa; pwd=123";
        SqlConnection connection = new SqlConnection(conn);

        try
        {
            connection.Open();
            SqlCommand comm = new SqlCommand();
            comm.Connection = connection;
            string str_sql = " update Student set flag_rest=' 已休学' where Sno='" + Sno + "' ";

            comm.CommandText = str_sql;
            //comm.ExecuteScalar();  //如果为查询语句，则用ExecuteScalar()；否则，用ExecuteNonQuery()
            comm.ExecuteNonQuery();


            Response.Write("<h1>成功办理休学！</h1>");

        }

        catch (SqlException ex)
        {
            Response.Write(ex.Message);
        }

        connection.Close();//关闭数据库连接

    }
}